extends MySprites

@onready var animation_player: AnimatedSprite2D = $Animation

func _init():
	# 在初始化时修改变量的默认值
	health = 20
	attack = 30
	defence = 20
	is_player = false
	physical_location = 1

func _ready() -> void:
	animation_player.play("Idle")

#哥布林的大招:恢复自己20%生命值
func use_ultimate_ability(_players: Array, _enemies: Array) -> void:
	var heal_value = int(attack * 0.2)
	animation_player.play("Attack")
	await animation_player.animation_finished
	health += heal_value
	animation_player.play("Idle")
	if is_player:
		Events.signal_enemy_turn.emit()
	else:
		Events.signal_player_turn.emit()
		
#哥布林的普通技能:恢复自己10%生命值
func use_basic_ability(_players: Array, _enemies: Array) -> void:
	var heal_value = int(attack * 0.1)
	animation_player.play("Attack")
	await animation_player.animation_finished
	health += heal_value
	animation_player.play("Idle")
	if is_player:
		Events.signal_enemy_turn.emit()
	else:
		Events.signal_player_turn.emit()

	
func my_sprite_killed() -> void:
	animation_player.play("Death")
	await animation_player.animation_finished
	visible = false
